package com.poorstu.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.common.base.web.BaseAction;
import com.poorstu.manager.RoleManager;
import com.poorstu.model.RoleMod;

public class ChangeRoleAction extends BaseAction {

	@Override//
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
			try {
				DynaActionForm dyaction=(DynaActionForm)form;
				int roleId=(Integer)dyaction.get("roleid");
				String roleName=(String)dyaction.get("rolename");
				String roleStatus=((Integer)dyaction.get("rolestatus")).toString();
				String[] power=(String[])dyaction.get("power");
				
				RoleMod roleMod=new RoleMod();
				roleMod.setRoleId(roleId);
				roleMod.setRoleName(roleName);
				roleMod.setRoleaStatus(roleStatus);
				
				RoleManager roleMeg=(RoleManager)getBean("roleMeg");
				
				boolean isSuc = roleMeg.updateRole(roleMod, power);
				
				if(!isSuc)
					return mapping.findForward("failure");
				return mapping.findForward("succdelete");
			} catch (Exception e) {
				e.printStackTrace();
				return mapping.findForward("failure");
			}
	}

}
